package com.example.mapper;

import com.example.entity.Student;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作student相关数据接口
*/
public interface StudentMapper {

    /**
     * 新增
     */
    int insert(Student student);

    /**
     * 删除
     */
    int deleteById(Integer id);

    /**
     * 修改
     */
    int updateById(Student student);

    /**
     * 根据ID查询
     */
    Student selectById(Integer id);

    /**
     * 查询所有
     */
    List<Student> selectAll(Student student);
    @Select("SELECT student.*, college.name AS collegeName, speciality.name AS specialityName, classes.name AS className " +
            "FROM student " +
            "LEFT JOIN college ON student.college_id = college.id " +
            "LEFT JOIN speciality ON student.speciality_id = speciality.id " +
            "LEFT JOIN classes ON student.class_id = classes.id " +
            "WHERE student.username = #{username}")

    Student selectByUsername(String username);
}